#!/usr/bin/python

import sys


SHORT_TYPES_DICT = {
    'P': 'biological_process',
    'F': 'molecular_function',
    'C': 'cellular_component',
}

def main():
    go_dict_fname = sys.argv[1]
    f = open(go_dict_fname)
    d = {}
    for line in f:
        id, type, name = line.strip().split('\t')
        d[id] = (type, name)
    f.close()

    for line_id, line in enumerate(sys.stdin):
        prob, funcs = line.strip().split('\t')
        print '#', line_id+1 #, prob
        tfuncs = dict([(t, f.split(',')) for (t,f) in (tf.split(':') for tf in funcs.split())])
        for t, funcs in tfuncs.iteritems():
            print '  %s:' % SHORT_TYPES_DICT[t]
            for f in funcs:
                print '   - %s' % d[f][1]



if __name__ == '__main__':
    main()

